<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bluejay Class Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Class/Bluejay" class="dashAnchor"></a>
    <a title="Bluejay Class Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html"> Docs</a> (44% documented)</p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html"> Reference</a>
        <img id="carat" src="../img/carat.png" />
        Bluejay Class Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/Bluejay.html">Bluejay</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/Peripheral.html">Peripheral</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/SynchronizedPeripheral.html">SynchronizedPeripheral</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Enums.html">Enums</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Enums/BackgroundRestoreMode.html">BackgroundRestoreMode</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/ConnectionResult.html">ConnectionResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/DisconnectionResult.html">DisconnectionResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/DiscoveryResult.html">DiscoveryResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/ListenAction.html">ListenAction</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/ReadResult.html">ReadResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/RunResult.html">RunResult</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/ScanAction.html">ScanAction</a>
              </li>
              <li class="nav-group-task">
                <a href="../Enums/WriteResult.html">WriteResult</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Extensions/CBManagerState.html">CBManagerState</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/CBPeripheral.html">CBPeripheral</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/CBPeripheralState.html">CBPeripheralState</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/CBService.html">CBService</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/Data.html">Data</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/Integer.html">Integer</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/Notification.html">Notification</a>
              </li>
              <li class="nav-group-task">
                <a href="../Extensions/String.html">String</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Protocols/ConnectionObserver.html">ConnectionObserver</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/ListenRestorer.html">ListenRestorer</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/RSSIObserver.html">RSSIObserver</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/Receivable.html">Receivable</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/Sendable.html">Sendable</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structs</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/DataPadding.html">DataPadding</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/PeripheralIdentifier.html">PeripheralIdentifier</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/ScanDiscovery.html">ScanDiscovery</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/ServiceIdentifier.html">ServiceIdentifier</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>Bluejay</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                </div>
              </div>
            <p>Bluejay is a simple wrapper around CoreBluetooth that focuses on making a common usage case as straight forward as possible: a single connected peripheral that the user is interacting with regularly (think most personal electronics devices that have an associated iOS app: fitness trackers, guitar amps, etc).</p>

<p>It also supports a few other niceties for simplifying usage, including automatic discovery of services and characteristics as they are used, as well as supporting a background task mode where the interaction with the device can be written as synchronous calls running on a background thread to avoid callback pyramids of death, or heavily chained promises.</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Public%20Properties"></a>
                <a name="//apple_ref/swift/Section/Public Properties" class="dashAnchor"></a>
                <a href="#/Public%20Properties">
                  <h3 class="section-name">Public Properties</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay4uuidV10Foundation4UUID"></a>
                    <a name="//apple_ref/swift/Property/uuid" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay4uuidV10Foundation4UUID">uuid</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Helps distinguish one Bluejay instance from another.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">uuid</span> <span class="o">=</span> <span class="kt">UUID</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay20isBluetoothAvailableSb"></a>
                    <a name="//apple_ref/swift/Property/isBluetoothAvailable" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay20isBluetoothAvailableSb">isBluetoothAvailable</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Allows checking whether Bluetooth is powered on.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isBluetoothAvailable</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay12isConnectingSb"></a>
                    <a name="//apple_ref/swift/Property/isConnecting" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay12isConnectingSb">isConnecting</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Allows checking whether Bluejay is currently connecting to a peripheral.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isConnecting</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay11isConnectedSb"></a>
                    <a name="//apple_ref/swift/Property/isConnected" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay11isConnectedSb">isConnected</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Allows checking whether Bluejay is currently connected to a peripheral.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isConnected</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay15isDisconnectingSb"></a>
                    <a name="//apple_ref/swift/Property/isDisconnecting" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay15isDisconnectingSb">isDisconnecting</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Allows checking whether Bluejay is currently disconnecting from a peripheral.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isDisconnecting</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vC7Bluejay7Bluejay10isScanningSb"></a>
                    <a name="//apple_ref/swift/Property/isScanning" class="dashAnchor"></a>
                    <a class="token" href="#/s:vC7Bluejay7Bluejay10isScanningSb">isScanning</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Allows checking whether Bluejay is currently scanning.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isScanning</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Initialization"></a>
                <a name="//apple_ref/swift/Section/Initialization" class="dashAnchor"></a>
                <a href="#/Initialization">
                  <h3 class="section-name">Initialization</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7BluejaycFT_S0_"></a>
                    <a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7BluejaycFT_S0_">init()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Initializing a Bluejay instance will not yet initialize the CoreBluetooth stack. An explicit call to start running a Bluejay instance after it is intialized is required because in cases where a state resotration is trying to restore a listen on a characteristic, a listen restorer must be available before the CoreBluetooth stack is re-initialized. This two-step startup allows you to insert and gaurantee the setup of your listen restorer in between the initialization of Bluejay and the initialization of the CoreBluetooth stack triggered via this call.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">override</span> <span class="nf">init</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay5startFT18connectionObserverGSqPS_18ConnectionObserver__17backgroundRestoreOS_21BackgroundRestoreMode_T_"></a>
                    <a name="//apple_ref/swift/Method/start(connectionObserver:backgroundRestore:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay5startFT18connectionObserverGSqPS_18ConnectionObserver__17backgroundRestoreOS_21BackgroundRestoreMode_T_">start(connectionObserver:backgroundRestore:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Starting Bluejay will initialize the CoreBluetooth stack. Initializing a Bluejay instance will not yet initialize the CoreBluetooth stack. An explicit call to start running a Bluejay instance after it is intialized is required because in cases where a state resotration is trying to restore a listen on a characteristic, a listen restorer must be available before the CoreBluetooth stack is re-initialized. This two-step startup allows you to insert and gaurantee the setup of your listen restorer in between the initialization of Bluejay and the initialization of the CoreBluetooth stack triggered via this call.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">(</span>
        <span class="n">connectionObserver</span> <span class="nv">observer</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ConnectionObserver.html">ConnectionObserver</a></span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
        <span class="n">backgroundRestore</span> <span class="nv">restoreMode</span><span class="p">:</span> <span class="kt"><a href="../Enums/BackgroundRestoreMode.html">BackgroundRestoreMode</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">disable</span>
        <span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>observer</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>An object interested in observing Bluetooth connection events and state changes. You can register more observers using the <code>register</code> function.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>restoreMode</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Determines whether Bluejay will opt-in to state restoration, and if so, can optionally provide a listen restorer as well for restoring listens.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay16cancelEverythingFGSqCSo7NSError_T_"></a>
                    <a name="//apple_ref/swift/Method/cancelEverything(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay16cancelEverythingFGSqCSo7NSError_T_">cancelEverything(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>This will cancel the current and all pending operations in the Bluejay queue, as well as stop any ongoing scan, and disconnect any connected peripheral.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">cancelEverything</span><span class="p">(</span><span class="n">_</span> <span class="nv">error</span><span class="p">:</span> <span class="kt">NSError</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>error</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>If nil, all tasks in the queue will be cancelled without any errors. If an error is provided, all tasks in the queue will be failed with the supplied error.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Events%20Registration"></a>
                <a name="//apple_ref/swift/Section/Events Registration" class="dashAnchor"></a>
                <a href="#/Events%20Registration">
                  <h3 class="section-name">Events Registration</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay8registerFT8observerPS_18ConnectionObserver__T_"></a>
                    <a name="//apple_ref/swift/Method/register(observer:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay8registerFT8observerPS_18ConnectionObserver__T_">register(observer:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Register for notifications on Bluetooth connection events and state changes. Unregistering is not required, Bluejay will unregister for you if the observer is no longer in memory.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">register</span><span class="p">(</span><span class="nv">observer</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ConnectionObserver.html">ConnectionObserver</a></span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>observer</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p></p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay10unregisterFT8observerPS_18ConnectionObserver__T_"></a>
                    <a name="//apple_ref/swift/Method/unregister(observer:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay10unregisterFT8observerPS_18ConnectionObserver__T_">unregister(observer:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Unregister for notifications on Bluetooth connection events and state changes. Unregistering is not required, Bluejay will unregister for you if the observer is no longer in memory.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">unregister</span><span class="p">(</span><span class="nv">observer</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ConnectionObserver.html">ConnectionObserver</a></span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>observer</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p></p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Scanning"></a>
                <a name="//apple_ref/swift/Section/Scanning" class="dashAnchor"></a>
                <a href="#/Scanning">
                  <h3 class="section-name">Scanning</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay4scanFT8durationSd15allowDuplicatesSb18serviceIdentifiersGSqGSaVS_17ServiceIdentifier__9discoveryFTVS_13ScanDiscoveryGSaS2___OS_10ScanAction7expiredGSqFTS2_GSaS2___S3__7stoppedFTGSaS2__GSqPs5Error___T__T_"></a>
                    <a name="//apple_ref/swift/Method/scan(duration:allowDuplicates:serviceIdentifiers:discovery:expired:stopped:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay4scanFT8durationSd15allowDuplicatesSb18serviceIdentifiersGSqGSaVS_17ServiceIdentifier__9discoveryFTVS_13ScanDiscoveryGSaS2___OS_10ScanAction7expiredGSqFTS2_GSaS2___S3__7stoppedFTGSaS2__GSqPs5Error___T__T_">scan(duration:allowDuplicates:serviceIdentifiers:discovery:expired:stopped:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Scan for the peripheral(s) specified.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">scan</span><span class="p">(</span>
        <span class="nv">duration</span><span class="p">:</span> <span class="kt">TimeInterval</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
        <span class="nv">allowDuplicates</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
        <span class="nv">serviceIdentifiers</span><span class="p">:</span> <span class="p">[</span><span class="kt"><a href="../Structs/ServiceIdentifier.html">ServiceIdentifier</a></span><span class="p">]?,</span>
        <span class="nv">discovery</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Structs/ScanDiscovery.html">ScanDiscovery</a></span><span class="p">,</span> <span class="p">[</span><span class="kt"><a href="../Structs/ScanDiscovery.html">ScanDiscovery</a></span><span class="p">])</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Enums/ScanAction.html">ScanAction</a></span><span class="p">,</span>
        <span class="nv">expired</span><span class="p">:</span> <span class="p">((</span><span class="kt"><a href="../Structs/ScanDiscovery.html">ScanDiscovery</a></span><span class="p">,</span> <span class="p">[</span><span class="kt"><a href="../Structs/ScanDiscovery.html">ScanDiscovery</a></span><span class="p">])</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Enums/ScanAction.html">ScanAction</a></span><span class="p">)?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
        <span class="nv">stopped</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">([</span><span class="kt"><a href="../Structs/ScanDiscovery.html">ScanDiscovery</a></span><span class="p">],</span> <span class="kt">Swift</span><span class="o">.</span><span class="kt">Error</span><span class="p">?)</span> <span class="o">-&gt;</span> <span class="kt">Void</span>
        <span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>duration</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Stops the scan when the duration in seconds is reached. Defaults to zero (indefinite).</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>allowDuplicates</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Determines whether a previously scanned peripheral is allowed to be discovered again.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>serviceIdentifiers</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Specifies what visible services the peripherals must have in order to be discovered.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>discovery</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called whenever a specified peripheral has been discovered.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>expired</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called whenever a previously discovered peripheral has not been seen again for a while, and Bluejay is predicting that it may no longer be in range. (Only for a scan with allowDuplicates enabled)</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>stopped</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called when the scan is finished and provides an error if there is any.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay12stopScanningFT_T_"></a>
                    <a name="//apple_ref/swift/Method/stopScanning()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay12stopScanningFT_T_">stopScanning()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Stops an ongoing scan if there is one, otherwise it does nothing.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stopScanning</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Connection"></a>
                <a name="//apple_ref/swift/Section/Connection" class="dashAnchor"></a>
                <a href="#/Connection">
                  <h3 class="section-name">Connection</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay7connectFTVS_20PeripheralIdentifier10completionFOS_16ConnectionResultT__T_"></a>
                    <a name="//apple_ref/swift/Method/connect(_:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay7connectFTVS_20PeripheralIdentifier10completionFOS_16ConnectionResultT__T_">connect(_:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Attempt to connect directly to a known peripheral. The call will fail if Bluetooth is not available, or if Bluejay is already connected. Making a connection request while Bluejay is scanning will also cause Bluejay to stop the current scan for you behind the scene prior to fulfilling your connection request.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">connect</span><span class="p">(</span><span class="n">_</span> <span class="nv">peripheralIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/PeripheralIdentifier.html">PeripheralIdentifier</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/ConnectionResult.html">ConnectionResult</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>peripheralIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The peripheral to connect to.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called when the connection request has fully finished and indicates whether it was successful, cancelled, or failed.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay10disconnectFT10completionGSqFOS_19DisconnectionResultT___T_"></a>
                    <a name="//apple_ref/swift/Method/disconnect(completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay10disconnectFT10completionGSqFOS_19DisconnectionResultT___T_">disconnect(completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Disconnect the currently connected peripheral. Providing a completion block is not necessary, but useful in most cases.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">disconnect</span><span class="p">(</span><span class="nv">completion</span><span class="p">:</span> <span class="p">((</span><span class="kt"><a href="../Enums/DisconnectionResult.html">DisconnectionResult</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called when the disconnection request has fully finished and indicates whether it was successful, cancelled, or failed.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Actions"></a>
                <a name="//apple_ref/swift/Section/Actions" class="dashAnchor"></a>
                <a href="#/Actions">
                  <h3 class="section-name">Actions</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay4readuRxS_10ReceivablerFT4fromVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_"></a>
                    <a name="//apple_ref/swift/Method/read(from:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay4readuRxS_10ReceivablerFT4fromVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_">read(from:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Read from the specified characteristic.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">read</span><span class="o">&lt;</span><span class="kt">R</span><span class="p">:</span> <span class="kt"><a href="../Protocols/Receivable.html">Receivable</a></span><span class="o">&gt;</span><span class="p">(</span><span class="n">from</span> <span class="nv">characteristicIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/ReadResult.html">ReadResult</a></span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>characteristicIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The characteristic to read from.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called with the result of the attempt to read from the specified characteristic.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay5writeuRxS_8SendablerFT2toVS_24CharacteristicIdentifier5valuex10completionFOS_11WriteResultT__T_"></a>
                    <a name="//apple_ref/swift/Method/write(to:value:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay5writeuRxS_8SendablerFT2toVS_24CharacteristicIdentifier5valuex10completionFOS_11WriteResultT__T_">write(to:value:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Write to the specified characteristic.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">write</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt"><a href="../Protocols/Sendable.html">Sendable</a></span><span class="o">&gt;</span><span class="p">(</span><span class="n">to</span> <span class="nv">characteristicIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a></span><span class="p">,</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">S</span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/WriteResult.html">WriteResult</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>characteristicIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The characteristic to write to.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called with the result of the attempt to write to the specified characteristic.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay6listenuRxS_10ReceivablerFT2toVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_"></a>
                    <a name="//apple_ref/swift/Method/listen(to:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay6listenuRxS_10ReceivablerFT2toVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_">listen(to:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Listen for notifications on the specified characteristic.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">listen</span><span class="o">&lt;</span><span class="kt">R</span><span class="p">:</span> <span class="kt"><a href="../Protocols/Receivable.html">Receivable</a></span><span class="o">&gt;</span><span class="p">(</span><span class="n">to</span> <span class="nv">characteristicIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/ReadResult.html">ReadResult</a></span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>characteristicIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The characteristic to listen to.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called with the result of the attempt to listen for notifications on the specified characteristic.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay9endListenFT2toVS_24CharacteristicIdentifier10completionGSqFOS_11WriteResultT___T_"></a>
                    <a name="//apple_ref/swift/Method/endListen(to:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay9endListenFT2toVS_24CharacteristicIdentifier10completionGSqFOS_11WriteResultT___T_">endListen(to:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>End listening on the specified characteristic.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">endListen</span><span class="p">(</span><span class="n">to</span> <span class="nv">characteristicIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="p">((</span><span class="kt"><a href="../Enums/WriteResult.html">WriteResult</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>characteristicIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The characteristic to stop listening to.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called with the result of the attempt to stop listening to the specified characteristic.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay13restoreListenuRxS_10ReceivablerFT2toVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_"></a>
                    <a name="//apple_ref/swift/Method/restoreListen(to:completion:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay13restoreListenuRxS_10ReceivablerFT2toVS_24CharacteristicIdentifier10completionFGOS_10ReadResultx_T__T_">restoreListen(to:completion:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Restore a (believed to be) active listening session, so if we start up in response to a notification, we can receive it.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">restoreListen</span><span class="o">&lt;</span><span class="kt">R</span><span class="p">:</span> <span class="kt"><a href="../Protocols/Receivable.html">Receivable</a></span><span class="o">&gt;</span><span class="p">(</span><span class="n">to</span> <span class="nv">characteristicIdentifier</span><span class="p">:</span> <span class="kt"><a href="../Structs/CharacteristicIdentifier.html">CharacteristicIdentifier</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/ReadResult.html">ReadResult</a></span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>characteristicIdentifier</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The characteristic that needs the restoration.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completion</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Called with the result of the attempt to restore the listen on the specified characteristic.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Background%20Task"></a>
                <a name="//apple_ref/swift/Section/Background Task" class="dashAnchor"></a>
                <a href="#/Background%20Task">
                  <h3 class="section-name">Background Task</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay3runFT14backgroundTaskFzCS_22SynchronizedPeripheralT_22completionOnMainThreadFGOS_9RunResultT__T__T_"></a>
                    <a name="//apple_ref/swift/Method/run(backgroundTask:completionOnMainThread:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay3runFT14backgroundTaskFzCS_22SynchronizedPeripheralT_22completionOnMainThreadFGOS_9RunResultT__T__T_">run(backgroundTask:completionOnMainThread:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>One of the three ways to run a background task using a synchronous interface to the Bluetooth peripheral. This is the simplest one as the background task will not return any typed values back to the completion block on finishing the background task, except for thrown errors, and it also doesn&rsquo;t provide an input for an object that might need thread safe access.</p>
<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    <p>Be careful not to access anything that is not thread safe inside background task.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">run</span><span class="p">(</span>
        <span class="nv">backgroundTask</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Classes/SynchronizedPeripheral.html">SynchronizedPeripheral</a></span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">,</span>
        <span class="nv">completionOnMainThread</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/RunResult.html">RunResult</a></span><span class="o">&lt;</span><span class="kt">Void</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>backgroundTask</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure with the jobs to be executed in the background.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completionOnMainThread</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure called on the main thread when the background task has either completed or failed.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay3runurFT14backgroundTaskFzCS_22SynchronizedPeripheralx22completionOnMainThreadFGOS_9RunResultx_T__T_"></a>
                    <a name="//apple_ref/swift/Method/run(backgroundTask:completionOnMainThread:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay3runurFT14backgroundTaskFzCS_22SynchronizedPeripheralx22completionOnMainThreadFGOS_9RunResultx_T__T_">run(backgroundTask:completionOnMainThread:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>One of the three ways to run a background task using a synchronous interface to the Bluetooth peripheral. This one allows the background task to potentially return a typed value back to the completion block on finishing the background task successfully.</p>
<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    <p>Be careful not to access anything that is not thread safe inside background task.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">run</span><span class="o">&lt;</span><span class="kt">Result</span><span class="o">&gt;</span><span class="p">(</span>
        <span class="nv">backgroundTask</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Classes/SynchronizedPeripheral.html">SynchronizedPeripheral</a></span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Result</span><span class="p">,</span>
        <span class="nv">completionOnMainThread</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/RunResult.html">RunResult</a></span><span class="o">&lt;</span><span class="kt">Result</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>backgroundTask</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure with the jobs to be executed in the background.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completionOnMainThread</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure called on the main thread when the background task has either completed or failed.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay3runu0_rFT8userDatax14backgroundTaskFzTCS_22SynchronizedPeripheralx_q_22completionOnMainThreadFGOS_9RunResultq__T__T_"></a>
                    <a name="//apple_ref/swift/Method/run(userData:backgroundTask:completionOnMainThread:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay3runu0_rFT8userDatax14backgroundTaskFzTCS_22SynchronizedPeripheralx_q_22completionOnMainThreadFGOS_9RunResultq__T__T_">run(userData:backgroundTask:completionOnMainThread:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>One of the three ways to run a background task using a synchronous interface to the Bluetooth peripheral. This one allows the background task to potentially return a typed value back to the completion block on finishing the background task successfully, as well as supplying an object for thread safe access inside the background task.</p>
<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    <p>Be careful not to access anything that is not thread safe inside background task.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">run</span><span class="o">&lt;</span><span class="kt">UserData</span><span class="p">,</span> <span class="kt">Result</span><span class="o">&gt;</span><span class="p">(</span>
        <span class="nv">userData</span><span class="p">:</span> <span class="kt">UserData</span><span class="p">,</span>
        <span class="nv">backgroundTask</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Classes/SynchronizedPeripheral.html">SynchronizedPeripheral</a></span><span class="p">,</span> <span class="kt">UserData</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Result</span><span class="p">,</span>
        <span class="nv">completionOnMainThread</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/RunResult.html">RunResult</a></span><span class="o">&lt;</span><span class="kt">Result</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>userData</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Any object you wish to have thread safe access inside background task.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>backgroundTask</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure with the jobs to be executed in the background.</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>completionOnMainThread</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A closure called on the main thread when the background task has either completed or failed.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Helpers"></a>
                <a name="//apple_ref/swift/Section/Helpers" class="dashAnchor"></a>
                <a href="#/Helpers">
                  <h3 class="section-name">Helpers</h3>
                </a>
              </div>
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:ZFC7Bluejay7Bluejay7combineFT9sendablesGSaPS_8Sendable___V10Foundation4Data"></a>
                    <a name="//apple_ref/swift/Method/combine(sendables:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:ZFC7Bluejay7Bluejay7combineFT9sendablesGSaPS_8Sendable___V10Foundation4Data">combine(sendables:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A helper function to take an array of Sendables and combine their data together.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">combine</span><span class="p">(</span><span class="nv">sendables</span><span class="p">:</span> <span class="p">[</span><span class="kt"><a href="../Protocols/Sendable.html">Sendable</a></span><span class="p">])</span> <span class="o">-&gt;</span> <span class="kt">Data</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>sendables</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>An array of Sendables whose Data should be appended in the order of the given array.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The resulting data of all the Sendables combined in the order of the passed in array.</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay28centralManagerDidUpdateStateFCSo16CBCentralManagerT_"></a>
                    <a name="//apple_ref/swift/Method/centralManagerDidUpdateState(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay28centralManagerDidUpdateStateFCSo16CBCentralManagerT_">centralManagerDidUpdateState(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager16willRestoreStateGVs10DictionarySSP___T_"></a>
                    <a name="//apple_ref/swift/Method/centralManager(_:willRestoreState:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager16willRestoreStateGVs10DictionarySSP___T_">centralManager(_:willRestoreState:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager10didConnectCSo12CBPeripheral_T_"></a>
                    <a name="//apple_ref/swift/Method/centralManager(_:didConnect:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager10didConnectCSo12CBPeripheral_T_">centralManager(_:didConnect:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager23didDisconnectPeripheralCSo12CBPeripheral5errorGSqPs5Error___T_"></a>
                    <a name="//apple_ref/swift/Method/centralManager(_:didDisconnectPeripheral:error:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager23didDisconnectPeripheralCSo12CBPeripheral5errorGSqPs5Error___T_">centralManager(_:didDisconnectPeripheral:error:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager16didFailToConnectCSo12CBPeripheral5errorGSqPs5Error___T_"></a>
                    <a name="//apple_ref/swift/Method/centralManager(_:didFailToConnect:error:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager16didFailToConnectCSo12CBPeripheral5errorGSqPs5Error___T_">centralManager(_:didFailToConnect:error:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager11didDiscoverCSo12CBPeripheral17advertisementDataGVs10DictionarySSP__4rssiCSo8NSNumber_T_"></a>
                    <a name="//apple_ref/swift/Method/centralManager(_:didDiscover:advertisementData:rssi:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FC7Bluejay7Bluejay14centralManagerFTCSo16CBCentralManager11didDiscoverCSo12CBPeripheral17advertisementDataGVs10DictionarySSP__4rssiCSo8NSNumber_T_">centralManager(_:didDiscover:advertisementData:rssi:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Undocumented</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">Bluejay</span><span class="p">:</span> <span class="kt">NSObject</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2017 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2017-06-02)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
